package com.ph.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ph.pojo.Result;
import com.ph.pojo.User;
import com.ph.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("ignore/sys/")
public class IgnoreController {
    @Autowired
    private UserService userService;
    // http://group-service/sys/ignore/user/findByPhone?phone=12345678901
    // http://group-service/sys/ignore
    // http://group-service/sys/user/login
    // http://group-service/sys/user
    @GetMapping("user/findByPhone")
    public Result findByPhone(Long phone){
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("phone",phone);
        return Result.success(userService.getOne(queryWrapper));
    }

    @GetMapping("user/findById/{id}")
    public Result findById(@PathVariable Integer id){
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",id);
        return Result.success(userService.getOne(queryWrapper));
    }

    @GetMapping("user/findById")
    public Result findById(Integer[] ids){
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("id",ids);
        return Result.success(userService.list(queryWrapper));
    }

}
